package com.monicaca.service;

import com.monicaca.bean.RKD;
import com.monicaca.dao.RKDDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class RKDService {
	@Autowired
	private RKDDAO RKDDAO;
	
	public RKD findByRKDId(int RKDId) {  
        return RKDDAO.findById(RKD.class, RKDId);  
    }  
	/*public RKD findByRKDName(RKD RKD) {
        return RKDDAO.findByName(RKD);
    }*/


    public List<RKD> findAll() {  
        return RKDDAO.findAll(RKD.class);  
    }
    @Transactional
    public int count2() {
        return RKDDAO.count2();
    }

    @Transactional  
    public void createRKD(RKD RKD) {  
    	RKDDAO.save(RKD);  
    }  
  
    @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW )

    public void updateRKD(RKD RKD) {  
    	RKDDAO.update(RKD);  
    }  
  
    @Transactional  
    public void deleteRKD(int RKDId) {  
    	RKDDAO.deleteById(RKD.class, RKDId);  
    }  
  
    @Transactional  
    public void deleteRKD(RKD RKD) {  
    	RKDDAO.delete(RKD);  
    }  
}
